import { Arduino } from 'blockly/core';

export const mixly_lib_fs_convert = function () {
    const DATA = Arduino.valueToCode(this, 'DATA', Arduino.ORDER_ATOMIC);
    return DATA + ';\n';
}

export const mixly_lib_fs_dir_pointer = function () {
    Arduino.definitions_['include_FS'] = '#include <FS.h>';
    const VALUE_INPUT_DIR = Arduino.valueToCode(this, 'DIR', Arduino.ORDER_ATOMIC);
    const FIELD_VAR = this.getFieldValue('VAR');
    return `Dir ${FIELD_VAR} = ${VALUE_INPUT_DIR};\n`;
}

export const mixly_lib_fs_file_pointer = function () {
    Arduino.definitions_['include_FS'] = '#include <FS.h>';
    const VALUE_INPUT_FILE = Arduino.valueToCode(this, 'FILE', Arduino.ORDER_ATOMIC);
    const FIELD_VAR = this.getFieldValue('VAR');
    return `File ${FIELD_VAR} = ${VALUE_INPUT_FILE};\n`;
}